#include "linked_queue.h"
#include <stdio.h>

void LinkedQueueDemo(void)
{
    LinkedQueue_t queue;
    UserInfo_t user;
    LinkedQueueInit(&queue);

    // 模拟入队三个用户
    for (int i = 0; i < 3; ++i) {
        UserInfo_t newUser;
        sprintf(newUser.info, "User_%d", i + 1);
        newUser.id = i + 1;
        if (LinkedQueueIn(&queue, &newUser) == LINKED_QUEUE_SUCCESS) {
            printf("入队：%s (ID: %d)\n", newUser.info, newUser.id);
        }
    }

    // 获取队头元素
    if (LinkedQueueGetFront(&queue, &user) == LINKED_QUEUE_SUCCESS) {
        printf("队头：%s (ID: %d)\n", user.info, user.id);
    }

    // 模拟出队两个用户
    for (int i = 0; i < 2; ++i) {
        if (LinkedQueueOut(&queue, &user) == LINKED_QUEUE_SUCCESS) {
            printf("出队：%s (ID: %d)\n", user.info, user.id);
        }
    }

    // 再次获取队头
    if (LinkedQueueGetFront(&queue, &user) == LINKED_QUEUE_SUCCESS) {
        printf("新队头：%s (ID: %d)\n", user.info, user.id);
    }

    // 清空队列
    LinkedQueueDestroy(&queue);
}